Repository navigation
fix: add C# references outside conditional ItemGroups - #770
Open
pcbeingused333 wants to merge 1 commit into
Open
pcbeingused333 wants to merge 1 commit into
pcbeingused333 wants to merge 1 commit into
Conversation
lean library add appended the reference to the last ItemGroup. A Condition on that group made the library available only in that configuration. Project and package references now use a project ItemGroup with no Condition, or a new one when every group is conditional.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #767
Root cause:
lean library addappends aProjectReferenceorPackageReferencetoItemGroup[last()]and never readsCondition. When the last group is limited to Debug, the command still succeeds and records the library, but Release builds cannot resolve the new type.Fix: both writers take the same group: the last direct
ItemGroupof the project that has noCondition. If every group is conditional, or there is none, a newItemGroupis added on the project element. Groups nested in aTargetare left alone. An existing reference is still not duplicated.Test: a project whose last or only
ItemGroupisCondition="'$(Configuration)' == 'Debug'"used to receive the new reference inside that group.test_add_csharp_project_to_csproj_does_not_use_a_conditional_item_group,test_add_csharp_project_to_csproj_with_only_a_conditional_item_group_adds_an_unconditional_one, andtest_add_csharp_package_to_csproj_does_not_use_a_conditional_item_groupcover that for project and package references. A fourth test checks that anItemGroupinside aTargetis not used when the project already has an unconditional group.This change was prepared with AI assistance.